|
|
|
|
|
|
|
Private Declare Function GetEnvironmentStrings Lib "kernel32" Alias
"GetEnvironmentStringsA" () As String
Private Sub cmdGetStrings_Click()
Dim Environment As String
Dim CurrentPosition As Long
Dim NewPosition
Environment = GetEnvironmentStrings()
Do
' Look for the next null character that separates the individual
' environment variables
NewPosition = InStr(CurrentPosition + 1, Environment, Chr$(0))
If NewPosition > CurrentPosition + 1 Then
' Found one, add up until the null character
Listl.AddItem Mid$(Environment, CurrentPosition + 1, _
NewPosition - CurrentPosition - 1)
' And start searching from the character that follows
CurrentPosition = NewPosition
Else
Exit Do
End If
Loop While True
End Sub |
|
|
|
|
|
|
|
|
Hey, this isn't the old days. We care about the environment! And this code crashes worse than an eggshell poisoned by DDT.1 Can you save the world, or at least this program? |
|
|
|
 |
|
 |
|
|
1 That is, on Windows NT. Windows 95/98 quietly ignores the error, leaving you with an empty string and the uncertain feeling that somewhere your memory has been corrupted in a way that will be impossible to track down. |
|
|
|
|
|